package com.exteam.model;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.exteam.common.util.CommLogger;
import com.exteam.common.util.CommUtils;

/**
 * Created by yanguoze on 2015/3/22.
 */
public class ModelApp extends Application {
    public static Context context;
    public static boolean isShowLog = true; //控制显示log
    public static boolean isDebug = true;
    public static String appEnName = "Model";

    public ModelApp() {
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate() {
        super.onCreate();
        CommLogger.d("ModelApp App init");
    }

    public void initData() {
        context = getApplicationContext();

        isDebug = Boolean.valueOf(context.getResources().getString(com.exteam.model.R.string.app_is_debug));
        isShowLog = Boolean.valueOf(context.getResources().getString(com.exteam.model.R.string.app_is_show_log));
        appEnName = getString(com.exteam.model.R.string.app_en_name);

        Log.d(appEnName, "isDebug:" + isDebug + " isShowLog:" + isShowLog);

        // 公共接口
        URLContainer.OFFICIAL_DOMAIN = context.getResources().getString(com.exteam.model.R.string.official_domain);
        URLContainer.TEST_DOMAIN = context.getResources().getString(com.exteam.model.R.string.test_domain);

        // 初始化日志
        CommLogger.initLogger(appEnName);

        // 初始化Utils
        CommUtils.initUitls(context);

        // 初始化日志
        CommLogger.setShowLog(isShowLog);

        if (isDebug) {
            URLContainer.setTestApi();
        } else {
            URLContainer.setOfficialApi();
        }
    }
}
